package cn.walls1717.wallsmall.order.feign;

import cn.walls1717.wallsmall.common.utils.R;
import cn.walls1717.wallsmall.order.pojo.vo.SkuHasStockVO;
import cn.walls1717.wallsmall.order.pojo.vo.WareSkuLockVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * 库存Feign
 *
 * @author walls1717
 * @since 2022/11/19 14:30
 **/
@FeignClient("wallsmall-ware")
public interface WareFeignService {

    /**
     * 根据skuId集合批量查询sku是否有库存
     *
     * @param skuIds skuId集合
     * @return skus的库存信息
     */
    @PostMapping("/ware/waresku/hasstock")
    List<SkuHasStockVO> listSkuWaresBySkuIds(@RequestBody List<Long> skuIds);

    /**
     * 根据addressId计算运费
     *
     * @param addrId addressId
     * @return 运费
     */
    @GetMapping("/ware/wareinfo/fare")
    R getFare(@RequestParam("addrId") Long addrId);

    /**
     * 锁定库存
     *
     * @param stockLock 被锁的sku数据
     * @return 锁定结果
     */
    @PostMapping("/ware/waresku/lock/order")
    R orderStockLock(@RequestBody WareSkuLockVO stockLock);

}
